package name.cyh.model.po;

import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

import static com.baomidou.mybatisplus.annotation.IdType.AUTO;

/**
 * @author 18433
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class OrderDetail {
    @TableId(type = AUTO)
    private int detailId;
    private int orderId;
    private int productId;
    private int quantity;
    private BigDecimal unitPrice;
    private BigDecimal totalPrice;
    private BigDecimal finalPrice;


    public void computeTotalPrice() {
        this.totalPrice = this.unitPrice.multiply(new BigDecimal(this.quantity));
    }
    public void computeFinalPrice(BigDecimal couponPrice) {
        this.finalPrice = couponPrice.multiply(new BigDecimal(this.quantity));
    }
}
